<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('维保维修工程水/电派工单项目列表')" />
    <link rel="stylesheet" href="../../../../../../../../../../../../css/Test.css">
</head>
<body class="gray-bg animated fadeInRight" style="background: white;">
     <div class="container-div">
         <div class="detail" style="margin-bottom: 10px; margin-top:15px;">
             <a class="btn btn-info btn-outline visible-xs-block" href="#" onclick="$.modal.closeTab()">返回</a>
             <nav class="nav" style="font-size: 15px; box-shadow: 0px 0px 0px 1px black;">
                 <a href="#" class="nav-item" active-color="orange" id="detail">详情</a>
                 <a href="#" class="nav-item" active-color="rebeccapurple" id="sheet">报告书联系单</a>
                 <a href="#" class="nav-item" active-color="rebeccapurple" id="engineers" style="color: black">维修工程</a>
                 <a href="#" class="nav-item" active-color="rebeccapurple" id="contact">维保项目合同</a>
             </nav>
         </div>
        <div class="row">
            <div class="col-sm-12 search-collapse" style="display: none">
                <form id="formId" th:object="${mtId}">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>项目名称：</label>
                                <input type="text" name="mMpname"/>
                            </li>
<!--                            <li>-->
<!--                                <label>联系单/报价单：</label>-->
<!--                                <input type="text" name="mPriceSheet"/>-->
<!--                            </li>-->
                            <li>
                                <label>项目状态：</label>
                                <select name="mStatus" th:with="type=${@dict.getType('maintenance_project_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}">
                                    </option>
                                </select>
<!--                                <select name="mStatus">-->
<!--                                    <option value="">所有</option>-->
<!--                                </select>-->
                            </li>
<!--                            <li>-->
<!--                                <label>发票/收据：</label>-->
<!--                                <input type="text" name="mReceipt"/>-->
<!--                            </li>-->
                            <li>
                                <label>维修费支付状态：</label>
                                <select name="mCoststatus" th:with="type=${@dict.getType('maintenance_coststatus')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
<!--                                <select name="mCoststatus">-->
<!--                                    <option value="">所有</option>-->
<!--                                </select>-->
                            </li>
<!--                            <li>-->
<!--                                <label>水/电派工单：</label>-->
<!--                                <input type="text" name="mJobOrder"/>-->
<!--                            </li>-->
                            <li class="select-time">
                                <label>创建时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginMDate]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endMDate]"/>
                            </li>
                            <li hidden>
                                <label>外键id：</label>
                                <input type="text" name="mtId"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="ruoyi:engineers:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="ruoyi:engineers:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="ruoyi:engineers:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="ruoyi:engineers:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('ruoyi:engineers:edit')}]];
        var removeFlag = [[${@permission.hasPermi('ruoyi:engineers:remove')}]];
        var prefix = ctx + "ruoyi/engineers";
        var mtId=[[*{mtId}]];
        //详情
        $("#detail").click(function () {
            location.href="/ruoyi/build/detail/" + mtId
        });
        //报告书联系单
        $("#sheet").click(function () {
            location.href= "/ruoyi/sheet/sheet/" + mtId;
        });
        //维修工程
        $("#engineers").click(function () {
            location.href="/ruoyi/engineers/engineers/" + mtId
        });
        //维保项目合同
        $("#contact").click(function () {
            location.href="/ruoyi/contact/contact/" + mtId
        });
        //维修项目状态
        var mStatus = [[${@dict.getType('maintenance_project_status')}]];
        //维修费支付状态
        var mCoststatus = [[${@dict.getType('maintenance_coststatus')}]];
        $(function() {
            var options = {
                url: prefix + "/lists/"+mtId,
                createUrl: prefix + "/add/"+mtId,
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "维保维修工程水/电派工单项目",
                showColumns: false,
                columns: [{
                    checkbox: true
                },
                {
                    field: 'mPid',
                    title: '项目id',
                    visible: false
                },
                {
                    field: 'mMpname',
                    title: '项目名称'
                },
                {
                    field: 'mPriceSheet',
                    title: '联系单/报价单',
                    align: 'center',
                    formatter: function(value, row, index) {
                        // return $.table.imageView(value);
                        var actions = [];
                        if(row.mPriceSheet==null){
                            actions.push('未上传');
                            return actions.join('');
                        }else{
                            return '<a href="javascript:downloadFile(\''+row.mPriceSheet+'\')">下载</a>';
                        }
                    }
                },
                {
                    field: 'mStatus',
                    title: '项目状态',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(mStatus, value);
                    }
                },
                {
                    field: 'mReceipt',
                    title: '发票/收据',
                    align: 'center',
                    formatter: function(value, row, index) {
                        // return $.table.imageView(value);
                        var actions = [];
                        if(row.mReceipt==null){
                            actions.push('未上传');
                            return actions.join('');
                        }else{
                            return '<a href="javascript:downloadFile(\''+row.mReceipt+'\')">下载</a>';
                        }
                    }
                },
                {
                    field: 'mCoststatus',
                    title: '维修费支付状态',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(mCoststatus, value);
                    }
                },
                {
                    field: 'mJobOrder',
                    title: '水/电派工单',
                    align: 'center',
                    formatter: function(value, row, index) {
                        // return $.table.imageView(value);
                        var actions = [];
                        if(row.mJobOrder==null){
                            actions.push('未上传');
                            return actions.join('');
                        }else{
                            return '<a href="javascript:downloadFile(\''+row.mJobOrder+'\')">下载</a>';
                        }
                    }
                },
                {
                    field: 'mDate',
                    title: '创建时间'
                },
                {
                    field: 'mtId',
                    title: '外键id',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        //谁为空 显示谁的修改上传按钮
                        if(row.mPriceSheet==null&&row.mReceipt!=null&&row.mJobOrder!=null){//联系单/报价单为空时 显示联系单/报价单修改上传按钮
                            actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="editmPriceSheet(\'' + row.mPid + '\')"><i class="fa fa-edit"></i>联系单/报价单上传</a> ');
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="clickss(\'' + row.mPid + '\')"><i class="fa fa-add"></i>维修项目器件</a> ');
                            // actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.mPid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="edit(\'' + row.mPid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.mPid + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }else if(row.mPriceSheet!=null&&row.mReceipt==null&&row.mJobOrder!=null){//发票/收据为空时 显示发票/收据修改上传按钮
                            actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="editmReceipt(\'' + row.mPid + '\')"><i class="fa fa-edit"></i>发票/收据上传</a> ');
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="clickss(\'' + row.mPid + '\')"><i class="fa fa-add"></i>维修项目器件</a> ');
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="edit(\'' + row.mPid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.mPid + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }else if(row.mPriceSheet!=null&&row.mReceipt!=null&&row.mJobOrder==null){//水/电派工单为空时  显示水/电派工单修改上传按钮
                            actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="editmJobOrder(\'' + row.mPid + '\')"><i class="fa fa-edit"></i>水/电派工单上传</a> ');
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="clickss(\'' + row.mPid + '\')"><i class="fa fa-add"></i>维修项目器件</a> ');
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="edit(\'' + row.mPid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.mPid + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }else if(row.mPriceSheet==null&&row.mReceipt==null&&row.mJobOrder!=null){//联系单/报价单 and 发票/收据 为空时 显示这俩修改上传按钮
                            actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="editmPriceSheet(\'' + row.mPid + '\')"><i class="fa fa-edit"></i>联系单/报价单上传</a> ');
                            actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="editmReceipt(\'' + row.mPid + '\')"><i class="fa fa-edit"></i>发票/收据上传</a> ');
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="clickss(\'' + row.mPid + '\')"><i class="fa fa-add"></i>维修项目器件</a> ');
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="edit(\'' + row.mPid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.mPid + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }else if(row.mPriceSheet==null&&row.mReceipt!=null&&row.mJobOrder==null){//联系单/报价单 and 水/电派工单 为空时 显示这俩修改上传按钮
                            actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="editmPriceSheet(\'' + row.mPid + '\')"><i class="fa fa-edit"></i>联系单/报价单上传</a> ');
                            actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="editmJobOrder(\'' + row.mPid + '\')"><i class="fa fa-edit"></i>水/电派工单上传</a> ');
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="clickss(\'' + row.mPid + '\')"><i class="fa fa-add"></i>维修项目器件</a> ');
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="edit(\'' + row.mPid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.mPid + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }else if(row.mPriceSheet!=null&&row.mReceipt==null&&row.mJobOrder==null){//发票/收据 and 水/电派工单 为空时 显示这俩修改上传按钮
                            actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="editmReceipt(\'' + row.mPid + '\')"><i class="fa fa-edit"></i>发票/收据上传</a> ');
                            actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="editmJobOrder(\'' + row.mPid + '\')"><i class="fa fa-edit"></i>水/电派工单上传</a> ');
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="clickss(\'' + row.mPid + '\')"><i class="fa fa-add"></i>维修项目器件</a> ');
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="edit(\'' + row.mPid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.mPid + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }else{
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="clickss(\'' + row.mPid + '\')"><i class="fa fa-add"></i>维修项目器件</a> ');
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="edit(\'' + row.mPid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.mPid + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function downloadFile(mPriceSheet) {
            window.location.href=ctx+"common/download/resource?resource="+mPriceSheet;
        }
        /*function downloadFile1(mReceipt) {
            window.location.href=ctx+"common/download/resource?resource="+mReceipt;
        }
        function downloadFile2(mJobOrder) {
            window.location.href=ctx+"common/download/resource?resource="+mJobOrder;
        }*/
        //联系单/报价单
        function editmPriceSheet(mPid) {
            var url = prefix + "/editmPriceSheet/"+mPid;
            $.modal.open("联系单/报价单上传",url);
        }
        //发票/收据
        function editmReceipt(mPid) {
            var url = prefix + "/editmReceipt/"+mPid;
            $.modal.open("发票/收据上传",url);
        }//水/电派工单
        function editmJobOrder(mPid) {
            var url = prefix + "/editmJobOrder/"+mPid;
            $.modal.open("水/电派工单上传",url);
        }
        function clickss(mPid) {
            var url = ctx + "ruoyi/moneys/moneys/"+mPid;
            $.modal.open("维修项目器件",url);
        }
        function edit(mPid) {
            var url = ctx + "ruoyi/engineers/edit/"+mPid;
            $.modal.open("编辑维修工程项目",url);
        }
    </script>
</body>
</html>